/**
 * Copyright © 2009 Qasky. All rights reserved.
 *
 * 项目主程序
 *
 * @author wanghongya
 * @version 0.0.0 2022/05/27
 *
 * History:
 * (author, date, desc)
 * (wanghongya, 20220527, 添加注释)
 */
import Vue from 'vue'
import router from './router'
import store from './store/index';
import App from './app.vue';

import Es6Promise from 'es6-promise'
import pick from 'lodash.pick'
import 'babel-polyfill'
import Antd from 'ant-design-vue/es'
import 'ant-design-vue/dist/antd.less'
import './assets/iconfont/iconfont.css'
import moment from 'moment'
import 'moment/locale/zh-cn'
import Util from '@/libs/util';
import plLazy from 'module/plLazy'
Vue.component('pl-lazy', plLazy)
import { post, get,uploadPost } from './libs/http'
import commonVariable from './libs/commonVariable'
import axios from "axios";
// 判断是否是ie9浏览器，如果是就执行针对ie9的一些兼容性处理

moment.locale('zh-cn')
Vue.use(Antd)

require('es6-promise').polyfill()
Es6Promise.polyfill()

if (document.documentMode && document.documentMode === 9) {
  Util.fixedProblemIE()
}

// 挂载全局
Vue.prototype.$axios = axios;
Vue.prototype.$pick = pick
Vue.prototype.hasPermission = Util.hasPermission;    // 权限方法
Vue.prototype.$post = post
Vue.prototype.$get = get
Vue.prototype.$uploadPost = uploadPost
Vue.prototype.$commonVariable = commonVariable
Vue.prototype.$api = process.env.NODE_ENV === 'development'?'/api':''    //本地使用需要添加'/api'，上传服务器为''

router.beforeEach((to, from, next) => {
    if (to.title) {
        document.title = to.title + '-- 测试工具控制传输'
    }
    next()
})

router.onError (( error ) => {
    const pattern = /Loading chunk (\d) +failed/g
    const isChunkLoadFailed = error.message.match (pattern)
    const targetPath = router.history.pending.fullPath
    sessionStorage.setItem('interceptorMsg2',error.message);
    if (isChunkLoadFailed) {
        router.replace ('/#' + targetPath)
    }
})

new Vue({
    el: '#app',
    router: router,
    store: store,
    render: h => h(App),
    mounted() {
    },
    created() {
    }
})
